﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Security.Permissions;
using System.ComponentModel;
using SharePointOfView.Properties;

namespace SharePointOfView.WebControls
{
    [AttributeUsage(AttributeTargets.All)]
    public class LocalizedCategoryAttribute : CategoryAttribute
    {
        // Fields
        private string categoryValue;

        // Methods
        public LocalizedCategoryAttribute()
            : this("Default")
        {
        }

        public LocalizedCategoryAttribute(string category)
        {
            this.categoryValue = category;
        }

        public override bool Equals(object obj)
        {
            return ((obj == this) || ((obj is CategoryAttribute) && this.Category.Equals(((CategoryAttribute)obj).Category)));
        }

        public override int GetHashCode()
        {
            return this.Category.GetHashCode();
        }

        protected override string GetLocalizedString(string value)
        {
            return Resources.ResourceManager.GetString(categoryValue);
        }

        public override bool IsDefaultAttribute()
        {
            return this.Category.Equals(Default.Category);
        }
    }
}
